﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace WpfBill.Common
{
    /// <summary>
    /// AppHelper
    /// 创建人：zhangyang
    /// 创建时间：2020/6/23 11:33:37
    /// </summary>
    class AppHelper
    {
        /// <summary>
        /// 登录
        /// </summary>
        public static bool Login()
        {
            try
            {
                Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
                //登录
                GUI.WinLogin winLogin = new GUI.WinLogin();
                if (winLogin.ShowDialog() != true)
                {//登录失败
                    Application.Current.Shutdown();//退出程序
                    return false;
                }
                Application.Current.MainWindow = new WpfBill.MainWindow();
                if (Application.Current.MainWindow == null)
                {
                    Application.Current.Shutdown();
                    return false;
                }
            }
            catch (Exception ex)
            {
                return false;
            }
            AppHelper.Main = Application.Current.MainWindow as MainWindow;
            Application.Current.MainWindow.Show();
            Application.Current.ShutdownMode = ShutdownMode.OnLastWindowClose;
            return true;
        }
        /// <summary>
        /// 主窗体
        /// </summary>
        public static MainWindow Main { get; private set; }


    }
}
